package fnord.illuminati.card.winconditions;

import java.util.LinkedList;
import java.util.Queue;

import fnord.illuminati.card.GroupCard;
import fnord.illuminati.card.WinCondition;
import fnord.network.server.Player;

public class GnomesWinCondition extends WinCondition {
	private static final long serialVersionUID = 1485862415725088926L;

	private final int _moneyToWin = 150;
	
	@Override
	public boolean hasWon(Player p) {
		Queue<GroupCard> cards = new LinkedList<GroupCard>();
		cards.add(p.getIlluminati());
		
		int money = 0;
		while (!cards.isEmpty()) {
			GroupCard current = cards.poll();
			System.out.println(cards.size());
			cards.addAll(current.getChildren());
			money += current.getMoney();
		}
		
		if (money>=_moneyToWin)
			return true;
		else
			return false;
	}
}
